package com.card323.crpg.item;

import java.util.ArrayList;

import com.card323.crpg.Hero;
import com.card323.crpg.effect.Effect;

public class Item {

	public String _name;
	String _use_msg;
	boolean _is_use_remove;
	private int _price;
	
	public Item(String name,String use_msg,int price)
	{
		_is_use_remove=true;
		_name=name;
		_use_msg=use_msg;
		_price=price;
	}
	ArrayList<Effect> _effects=new ArrayList<Effect>();
	public void use_item(Hero _hero,int index)
	{
		_hero.get_bi().send_message_to_all(_hero.get_name() + _use_msg + _name);
		for(Effect effect : _effects)
		{
			effect.affect(_hero);
		}
		if(_is_use_remove)
		{
			_hero.remove_item(index);
		}
	}
	public boolean is_null_item()
	{
		return _name.equals("");
	}
	public void add_effect(Effect e)
	{
		_effects.add(e);
	}
	public String get_item_info()
	{
		StringBuffer sb=new StringBuffer();
		for(Effect effect : _effects)
		{
			sb.append(effect.get_effect_info());
			sb.append(",");
		}
		return sb.toString();
	}
	public int get_price() {
		return _price;
		
	}
}
